<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Goods extends Model
{
    //绑定数据表
    protected $table='goods';

    //添加数据
    public function addData($request){
        $path = $request->file('goods_img')->store('uploads');
        $this->goods_name=$request['goods_name'];
        $this->goods_price=$request['goods_price'];
        $this->goods_img=$path;
        $this->goods_mags=$request['goods_mags'];
        return $this->save();
    }

    //分页查询数据
    public function findData(){
        return $this->paginate('10');
    }

    //删除数据
    public function delData($request){
        return $this->where('goods_id',$request['id'])->delete();
    }

}
